import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_juwo/common/common_index.dart';

class MemberView {
  //会员列表
  static memberList(var data) {
    return Expanded(
      child: ListView.builder(
          shrinkWrap: true,
          itemCount: data.length,
          itemBuilder: (BuildContext context, int index) {
            return _memberItem(data[index]);
          }),
    );
  }

  static circular() {
    return Container(
      width: ScrUtil.w(750),
      height: ScrUtil.w(25),
      color: Colors.white,
      child: Container(
        width: ScrUtil.w(750),
        height: ScrUtil.w(25),
        decoration: BoxDecoration(
            color: Colours.cbg1,
            borderRadius:
                BorderRadius.vertical(top: Radius.circular(ScrUtil.w(25)))),
      ),
    );
  }

  //头部统计的数据
  static census(num all, num active7, num notActive, num notDo) {
    return Container(
      height: ScrUtil.w(205),
      color: Colors.white,
      alignment: Alignment.center,
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          _censusItem("所有会员", all),
          _censusItem("7日活跃", active7),
          _censusItem("不活跃", notActive),
          _censusItem("未做单", notDo),
        ],
      ),
    );
  }

  static _censusItem(String title, num member) {
    return Expanded(
      child: Container(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Container(
              child: UiUtils.t(title, size: 24, color: Colours.cText1),
            ),
            Container(
              margin: UiUtils.edgeOnly(t: 20),
              child: UiUtils.t("$member",
                  size: 48, color: Colours.cText0, font: Font.PingFangBlod),
            )
          ],
        ),
      ),
    );
  }

  static _memberItem(item) {
    return Column(
      children: <Widget>[
        Container(
          height: ScrUtil.w(88),
          padding: UiUtils.edgeOnly(l: 60, r: 60),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              UiUtils.t(item["time"], size: 24, color: Colours.cText1),
              UiUtils.t(item["real_name"] ? "已实名" : "未实名",
                  size: 24, color: Colours.cText2)
            ],
          ),
        ),
        Container(
          height: ScrUtil.w(483),
          margin: UiUtils.edgeOnly(l: 30, r: 30),
          padding: UiUtils.edgeOnly(l: 30, r: 30, t: 30, b: 30),
          decoration: BoxDecoration(
              color: Colors.white, borderRadius: BorderRadius.circular(10)),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Container(
                        child: UiUtils.t(item["phone"],
                            size: 36,
                            font: Font.PingFangBlod,
                            color: Colours.cText0),
                      ),
                      Container(
                        margin: UiUtils.edgeOnly(t: ScrUtil.w(30)),
                        child: Row(
                          children: <Widget>[
                            _labItem(item["is_vip"] ? "尊贵VIP" : "普通会员",
                                Color.fromARGB(255, 255, 173, 16)),
                            _labItem(item["join_type"],
                                Color.fromARGB(255, 251, 148, 67)),
                          ],
                        ),
                      )
                    ],
                  ),
                  Container(
                    padding: UiUtils.edgeOnly(l: 30),
                    height: ScrUtil.w(152),
                    width: ScrUtil.w(300),
                    decoration: BoxDecoration(color: Colours.cbg2),
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        _rightMsg("加入平台:${item["join_days"]}"),
                        _rightMsg("累计做单:${item["all_order"]}"),
                        _rightMsg("累计贡献:${item["all_contribution"]}"),
                      ],
                    ),
                  )
                ],
              ),
              Container(

                child: UiUtils.t("最后一次做单:", size: 28, color: Colours.cText1),
              ),
              Container(
                margin: UiUtils.edgeOnly(t: 30,b: 40),
                child: UiUtils.t("${item["last_time"]}",
                    size: 28, color: Colours.cText0),
              ),
              Container(
                child: UiUtils.t("账号数量:", size: 28, color: Colours.cText1),
              ),
              Container(
                margin: UiUtils.edgeOnly(t: 30),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: <Widget>[
                    _accountNum("淘宝", item["num_account_tb"],
                        Color.fromARGB(255, 253, 141, 31)),
                    _accountNum("京东", item["num_account_jd"],
                        Color.fromARGB(255, 266, 33, 28)),
                    _accountNum("拼多多", item["num_account_pdd"],
                        Color.fromARGB(255, 0, 47, 140)),
                    _accountNum("抖音", item["num_account_dy"],
                        Color.fromARGB(255, 28, 185, 85)),
                    _accountNum("快手", item["num_account_ks"],
                        Color.fromARGB(255, 249, 121, 0)),
                  ],
                ),
              )
            ],
          ),
        )
      ],
    );
  }

  static _accountNum(String name, num, Color color) {
    return Container(
      child: Row(
        children: <Widget>[
          Container(
            height: ScrUtil.w(10),
            width: ScrUtil.w(10),
            decoration: BoxDecoration(
              color: color,
              borderRadius: BorderRadius.circular(16),
            ),
          ),
          Container(
            margin: UiUtils.edgeOnly(l: 10),
              child: UiUtils.t("$name:$num", size: 28, color: Colours.cText0))
        ],
      ),
    );
  }

  static _labItem(String name, Color color) {
    return Container(
      margin: UiUtils.edgeOnly(r: 30),
      width: ScrUtil.w(120),
      height: ScrUtil.w(38),
      alignment: Alignment.center,
      decoration: BoxDecoration(
          color: color,
          borderRadius: BorderRadius.only(
              topLeft: Radius.circular(10),
              topRight: Radius.circular(10),
              bottomRight: Radius.circular(10))),
      child: UiUtils.t(name, color: Colors.white, size: 22),
    );
  }

  static _rightMsg(String txt) {
    return Container(
      child: UiUtils.t(txt, color: Colours.cText3, size: 24),
    );
  }
}
